import { FormEffectHooks } from '@formily/antd';
import { Linkage, useLinkageUtils } from './use-linkage-utils';

const { onFieldValueChange$ } = FormEffectHooks;
const linkage = useLinkageUtils();

// 是否有必要
const events = {
  onFieldValueChang: (self: string, cb?: (linkage: Linkage, value: any) => void) => {
    onFieldValueChange$(self).subscribe(({ value }) => {
      if (cb) {
        cb(linkage, value);
      }
    });
  },
};

export default events;
